78. 子集
class Solution {
    //选/不选
    List<Integer> path;
    List<List<Integer>> ret;
    int n;

    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        n = nums.length;

        dfs(nums, 0);
        return ret;
    }

    public void dfs(int[] nums, int pos) {
        if (pos == nums.length) {
            ret.add(new ArrayList<>(path));
            return;
        }

        //选
        path.add(nums[pos]);
        dfs(nums, pos + 1);
        path.remove(path.size() - 1);
        //不选
        dfs(nums, pos + 1);
    }
}